import request from "@/utils/request";

let cacheAgentList = [];

export default {
  name: 'AllAgentMixin',
  data(){
    return {
      allAgentList: [], // 所有代理
    }
  },
  computed: {
    // 正常合作的代理
    agentList(){
      return this.allAgentList.filter(item => item.status === 1);
    }
  },
  created(){
    this.getAgentList();
  },
  methods: {
    getAgentList(){
      if(cacheAgentList.length > 0){
        this.allAgentList = cacheAgentList
      }else{
        request({
          url: '/agent/getAllAgent'
        })
          .then(res=>{
            this.allAgentList = res.data
            cacheAgentList = res.data
          })
      }
    },
  }


}
